import http from '../util/http'
import encode from '../util/encode'

export function getCode(phone){
  return http.post('/user/code',{phone})
}
export function checkCode(option={}){
  return http.post('/user/checkCode',option)
}
export function register(option){
  option.password = encode(option.password)
  option.passwordPay = encode(option.passwordPay)
  return http.post('/user/register',option)
}

export function login (option){
  if(option.type==1){
    option.password = encode(option.password)
  }
  return http.post('/user/login',option)
}

export function signout(){
  return http.get('/user/signout')
}

export function getOrderList(state){
  return http.get('/cart/list',{state})
}

export function getProductInfo(id){
  return http.get('/product/info',{id})
}

export function  addCart(option){
  return http.post('/cart/add',option)
}